home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / graphics / percentg / percent.frm < prev    next >
Text File  |  1995-03-21  |  4KB  |  129 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00FFFFFF&
  4.    BorderStyle     =   1  'Fixed Single
  5.    ClientHeight    =   105
  6.    ClientLeft      =   4080
  7.    ClientTop       =   4650
  8.    ClientWidth     =   5385
  9.    ClipControls    =   0   'False
  10.    Enabled         =   0   'False
  11.    Height          =   510
  12.    Left            =   4020
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   105
  17.    ScaleWidth      =   5385
  18.    Top             =   4305
  19.    Width           =   5505
  20.    Begin Label Label2 
  21.       Alignment       =   2  'Center
  22.       AutoSize        =   -1  'True
  23.       BackColor       =   &H000000FF&
  24.       BackStyle       =   0  'Transparent
  25.       Caption         =   "10%"
  26.       Height          =   195
  27.       Left            =   2040
  28.       TabIndex        =   1
  29.       Top             =   0
  30.       Width           =   375
  31.    End
  32.    Begin Label Label1 
  33.       Alignment       =   2  'Center
  34.       BackColor       =   &H000000FF&
  35.       Height          =   375
  36.       Left            =   0
  37.       TabIndex        =   0
  38.       Top             =   0
  39.       Width           =   1695
  40.    End
  41. End
  42. DefInt A-Z
  43. Option Explicit
  44. Declare Function GetWindowWord% Lib "User" (ByVal hWnd%, ByVal nIndex%)
  45. Declare Function SetWindowWord% Lib "User" (ByVal hWnd%, ByVal nIndex%, ByVal wNewWord%)
  46. Declare Function GetWindowLong& Lib "User" (ByVal hWnd%, ByVal nIndex%)
  47. Declare Function SetWindowLong& Lib "User" (ByVal hWnd%, ByVal nIndex%, ByVal dwNewLong&)
  48. Const GWW_ID = (-12)
  49. Const GWL_STYLE = (-16)
  50. Const WS_DLGFRAME = &H400000
  51. Const WS_SYSMENU = &H80000
  52. Const WS_MINIMIZEBOX = &H20000
  53. Const WS_MAXIMIZEBOX = &H10000
  54.  
  55. Sub Form_Load ()
  56.     Dim r
  57.     titlebar form1, False
  58.     label1.Width = 0
  59.     r = DoEvents()
  60.     form_resize
  61. End Sub
  62.  
  63. Sub form_resize ()
  64.     form1.Height = 300
  65.     label1.Height = form1.Height
  66.     Label2.Left = form1.Width / 2.25
  67.     Label2.Top = (label1.Height / 2) - (Label2.Height / 2)
  68. End Sub
  69.  
  70. Sub titlebar (frm As Form, ShowTitle)
  71.    Static Oldhmenu, SavedStyle&
  72.  
  73.    Dim NewStyle&, t&
  74.  
  75.    If ShowTitle Then
  76.       'get the current style attributes
  77.       NewStyle& = GetWindowLong&(frm.hWnd, GWL_STYLE)
  78.       
  79.       'set only the attributes that were removed earlier
  80.       NewStyle& = NewStyle& Or SavedStyle&
  81.       
  82.       're-establish the menu
  83.       If Oldhmenu <> 0 Then
  84.      t& = SetWindowWord%(frm.hWnd, GWW_ID, Oldhmenu)
  85.       End If
  86.       
  87.       'set the new style
  88.       t& = SetWindowLong&(frm.hWnd, GWL_STYLE, NewStyle&)
  89.       
  90.       'force VB to update the form
  91.       frm.Left = frm.Left
  92.       frm.Refresh
  93.    Else
  94.       'get the current style attributes
  95.       NewStyle& = GetWindowLong&(frm.hWnd, GWL_STYLE)
  96.  
  97.       'determine whether the form has a dialog frame, a ControlBox,
  98.       'a minimize button, or a maximize button and save this info.
  99.       'for later use
  100.       SavedStyle& = 0
  101.       SavedStyle& = SavedStyle& Or (NewStyle& And WS_DLGFRAME)
  102.       SavedStyle& = SavedStyle& Or (NewStyle& And WS_SYSMENU)
  103.       SavedStyle& = SavedStyle& Or (NewStyle& And WS_MINIMIZEBOX)
  104.       SavedStyle& = SavedStyle& Or (NewStyle& And WS_MAXIMIZEBOX)
  105.  
  106.       'remove the attributes for a dialog frame, a ControlBox, a minimize
  107.       'button and a maximize button
  108.       NewStyle& = NewStyle& And Not WS_DLGFRAME
  109.       NewStyle& = NewStyle& And Not WS_SYSMENU
  110.       NewStyle& = NewStyle& And Not WS_MINIMIZEBOX
  111.       NewStyle& = NewStyle& And Not WS_MAXIMIZEBOX
  112.  
  113.       'is there a menu associated with this form?
  114.       Oldhmenu = GetWindowWord%(frm.hWnd, GWW_ID)
  115.       If Oldhmenu <> 0 Then
  116.      'yes-zero it the menu handle
  117.      t& = SetWindowWord%(frm.hWnd, GWW_ID, 0)
  118.       End If
  119.    
  120.       'set the new style
  121.       t& = SetWindowLong&(frm.hWnd, GWL_STYLE, NewStyle&)
  122.  
  123.       'force VB to update the form and get rid of the title bar
  124.       frm.Left = frm.Left
  125.       frm.Refresh
  126.    End If
  127. End Sub
  128.  
  129.